<?php
//用户留言信息处理
	namespace Application\Home\Controller;
	use Application\Home\Model\Message as MessageModel;
	class Message{
		public function index(){
			if(IS_POST){
				
				if($_POST['name']=='' || $_POST['phone']==''){
					echo "<script>
							alert('请输入个人信息');
							window.location.href='contact.html#form';
						</script>";
					exit;					
				}
				
				$message = new MessageModel();
				$message->attributes->name = $_POST['name'];
				$message->attributes->company = $_POST['company'];				
				$message->attributes->phone = $_POST['phone'];
				$message->attributes->Email = $_POST['Email'];
				$message->attributes->user_message = $_POST['user_message'];
				$message->attributes->time = time();
				
				if($message->save()){
						echo "<script>alert('信息提交成功');
						window.location.href='contact.html#form';</script>";
						exit;
				}
							
			}else{
				echo "<script>alert('信息提交失败');
				window.location.href='contact.html#form';</script>";
				exit;
			}
			
		}
	}
?>